home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_079 / queryany / queryany.asm < prev    next >
Assembly Source File  |  1992-05-06  |  3KB  |  149 lines

  1. * QueryAny v2.0 - make decisions from within scripts
  2. * by  Mark W. Smith
  3. *
  4. *                © 1987 Smithware
  5. *                 Cincinnati, OH
  6. * ------------------------------------------------------------------------------
  7. * PROGRAM REVISIONS:
  8. *
  9. * v1.0 Lattice C - 15000+ bytes
  10. * v1.1 Lattice C - 15000+ bytes
  11. * v1.2 Aztec C   - 5244 bytes
  12. * v2.0 Assembly  - 352 bytes
  13. *
  14. * ------------------------------------------------------------------------------
  15. *  Version 1.0 would respond as follows:
  16. *
  17. *  1> QueryAny "Zing!"
  18. *  Do you wish to install 'Zing!' (y/n) ?
  19. *  1>
  20. * ------------------------------------------------------------------------------
  21. *  Version 1.1 now allows you to phrase it yourself:
  22. *
  23. *  1> QueryAny "Do you wish to install 'Zing!'"
  24. *  Do you wish to install 'Zing!' (y/n) ? y
  25. *  1>
  26. * ------------------------------------------------------------------------------
  27. *  Version 1.2 converted to Manx Aztec C.
  28. * ------------------------------------------------------------------------------
  29. *  Version 2.0 now in assembly, with "" delimeters removed:
  30. *
  31. *  1> QueryAny Do you wish to install 'Zing!'
  32. *  Do you wish to install 'Zing!' (y/n) ? y
  33. *  1>
  34. * ------------------------------------------------------------------------------
  35. * Included in this arc is an example of usage within the Startup-Sequence.
  36. * I have tried to make this program as generic as possible, so the user has
  37. * complete control over it, but kept the ' (y/n) ? ' at the end of the arg.
  38. * ------------------------------------------------------------------------------
  39.  
  40.  
  41.  
  42.     XREF    _AbsExecBase
  43.     XREF    _LVOOpenLibrary
  44.  
  45.     XREF    _LVOInput
  46.     XREF    _LVOOutput
  47.  
  48.     XREF    _LVORead
  49.     XREF    _LVOWrite
  50.  
  51.  
  52.  
  53. * Read and Write MACROS
  54.  
  55. WriteFile macro                ;File, String, Len
  56.     move.l    \1,d1
  57.     move.l    \2,d2
  58.     move.l    \3,d3
  59.     jsr    _LVOWrite(a6)
  60.     endm
  61.  
  62. ReadFile macro                ;File, Buffer, Len
  63.     move.l    \1,d1
  64.     move.l    \2,d2
  65.     move.l    \3,d3
  66.     jsr    _LVORead(a6)
  67.     endm
  68.  
  69.  
  70.  
  71. * Save cmd line arg pointers
  72.  
  73.     movem.l    a0/d0,-(sp)
  74.  
  75.  
  76.  
  77. * Open DOS library
  78.  
  79.     move.l    _AbsExecBase,a6
  80.     move.l    #DOS_Name,a1
  81.     clr.l    d0
  82.     jsr    _LVOOpenLibrary(a6)
  83.     move.l    d0,a6
  84.     tst.l    d0
  85.     bne    Continue        ;branch if arg exists
  86.     movem.l    (sp)+,a0/d0        ;otherwise, restore stack & quit
  87.     clr.l    d0
  88.     bra    Quit
  89.  
  90. Continue:
  91.     jsr    _LVOInput(a6)        ;get stdin
  92.     move.l    d0,StdIn
  93.     beq    Quit
  94.  
  95.     jsr    _LVOOutput(a6)        ;get stdout
  96.     move.l    d0,StdOut
  97.     beq    Quit
  98.  
  99.     movem.l    (sp)+,a0/d0        ;pop args from stack
  100.     subq.l    #1,d0            ;remove lf from cmd line arg
  101.     WriteFile    StdOut,a0,d0
  102.     WriteFile    StdOut,#Prompt,#Prompt_Len
  103.     ReadFile    StdIn,#Response,#2
  104.     move.b        Response,d0
  105.     cmpi.b        #'Y',d0
  106.     beq        No_Warning
  107.     cmpi.b        #'y',d0
  108.     beq        No_Warning
  109.     move.l        #5,d0
  110.     bra        Quit
  111.  
  112. No_Warning:
  113.     clr.l    d0
  114.  
  115. Quit:
  116.     rts
  117.  
  118.  
  119.  
  120.  
  121.     SECTION    data,DATA
  122.  
  123. DOS_Name:
  124.     dc.b    'dos.library',0
  125.  
  126. Prompt:
  127.     dc.b    ' (y/n) ? '
  128.  
  129. Prompt_Len equ *-Prompt
  130.  
  131.  
  132.  
  133.     SECTION    mem,BSS
  134.  
  135. StdIn    ds.l    1            ;input file handle
  136. StdOut    ds.l    1            ;output file handle
  137.  
  138. Response  ds.l  1
  139.  
  140.  
  141.     end
  142.  
  143.  
  144.  
  145. * REMEMBER to support NORML !!
  146. * the National Organization for the Reform of Marijuana Laws
  147.  
  148.  
  149.